<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>23-自定义指令</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style></style>
  </head>
  <body>
    <div id="app">
      <input type="text" v-model="msg" v-focus />
    </div>
    <script>
      Vue.directive('focus', {
        inserted: function (el) {
          el.focus();
        },
      });
      var vm = new Vue({
        el: '#app',
        data: {
          msg: '3',
        },
        methods: {},
      });
    </script>
  </body>
</html>
